import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:namewava/pages/mine/widgets/jc_mine_comment_item.dart';
import 'package:namewava/utils/jc_cache.dart';
import 'package:namewava/utils/jc_image_path.dart';
import 'package:namewava/utils/jc_nav.dart';
import 'package:namewava/utils/jc_screenutil_info.dart';
import 'package:namewava/utils/jc_text_style.dart';

class JcAbout extends StatefulWidget {
  const JcAbout({super.key});

  @override
  State<JcAbout> createState() => _JcAboutState();
}

class _JcAboutState extends State<JcAbout> {
  RxString version = ''.obs;
  RxString appName = ''.obs;
  @override
  void initState() {
    super.initState();
    var appInfo = JcCache.getInstance().get('appinfo');
    version.value = jsonDecode(appInfo)['ver'];
    appName.value = jsonDecode(appInfo)['appName'];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: null,
      body: _aboutWidget(),
    );
  }

  _aboutWidget() {
    return Container(
      width: JcScreenutilInfo.screenWidth,
      height: JcScreenutilInfo.screenHeight,
      decoration: const BoxDecoration(
          image: DecorationImage(
              image: AssetImage(JcImagePath.jcMinePageBg), fit: BoxFit.fill)),
      child: Column(
        children: [
          JcNav(
            title: 'About',
            backFunction: () {
              Get.back();
            },
          ),
          SizedBox(
            height: 65.h,
          ),
          Image.asset(
            JcImagePath.jcWavaLogo,
            width: 100.w,
            height: 100.w,
          ),
          Obx(() {
            return Text(
              appName.value,
              style: JcTextStyle.octoberDevanagariMediumTextStyle(
                  17.sp, Colors.black,
                  fWeight: FontWeight.w500),
            );
          }),
          SizedBox(
            height: 25.h,
          ),
          Obx(() {
            return JcMineCommentItem(
              title: 'Version',
              type: ItemType.text,
              rightValue: 'V ${version.value}',
            );
          }),
          // _aboutItemWidget('Version', 0),
          const JcMineCommentItem(
              title: 'Terms and Conditons', type: ItemType.protocol),
          // _aboutItemWidget('Terms and Conditons', 1),
          const JcMineCommentItem(
              title: 'Privacy Policy', type: ItemType.privacyPolicy),
          //  _aboutItemWidget('Privacy Policy', 2),
        ],
      ),
    );
  }

  // _aboutItemWidget(String info, int type) {
  //   return GestureDetector(
  //     child: Container(
  //       height: 56.h,
  //       padding: EdgeInsets.only(left: 19.w, right: 15.w),
  //       margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.w),
  //       decoration: BoxDecoration(
  //           color: const Color(0xFFF9F9F9),
  //           borderRadius: BorderRadius.circular(28.h)),
  //       child: Row(
  //         mainAxisAlignment: MainAxisAlignment.spaceBetween,
  //         crossAxisAlignment: CrossAxisAlignment.center,
  //         children: [
  //           Text(
  //             info,
  //             style: JcTextStyle.octoberDevanagariRegularTextStyle(
  //                 15.sp, Colors.black),
  //           ),
  //           type == 0
  //               ? Obx(() {
  //                   return Text(
  //                     version.value,
  //                     style: JcTextStyle.octoberDevanagariRegularTextStyle(
  //                         16.sp, Colors.black),
  //                   );
  //                 })
  //               : const SizedBox(
  //                   width: 0,
  //                 )
  //         ],
  //       ),
  //     ),
  //     onTap: () {
  //       if (type != 0) {
  //         JcPrivacyProtocol.launchPrivacyProtocol(type - 1);
  //       }
  //     },
  //   );
  // }
}
